<?php


namespace app\admin\controller;

use think\Controller;
use think\Db;
use think\helper\Time;

class Index extends Base
{

    public function index()
    {
        return $this->fetch();
    }

    /**
     * 代办事项
     * @return \think\response\Json
     */
    public function daiban()
    {

        //施工中
        $shigong = Db::name('project_stage')
            ->where('status', '>', 0)
            ->where('status', '<', 3)
            ->count();
        //总项目
        $xiangmu = Db::name('project')->count();
        //商品总数
        $goods = Db::name('goods')->count();
        //提现申请
        $tixian = Db::name('cash_manager')->where('status', 0)->count();

        return json(['code' => 1, 'shigong' => $shigong, 'xiangmu' => $xiangmu, 'shangpin' => $goods, 'tixian' => $tixian]);

    }

    /**
     * 访问统计
     * 只统计首页
     * @return \think\response\Json
     */
    public function pv_uv()
    {


    }

    /**
     * 获取访问统计
     * @return \think\response\Json
     */
    public function get_pv_uv()
    {

    }


    /**
     * 近七日用户增长量
     */
    public function user_line()
    {


        $data = [];
        $value=[];
        for ($i = 7; $i>0; $i--) {

            $ds = Time::daysAgo($i);
            $ds2 = date('Y-m-d', $ds);
            $ds3 = strtotime($ds2);
            $ds4 = $ds3 + 86400;

            $ky = date('n-d', $ds3);
            $count = Db::name('user')->where('create_time', '>', $ds3)
                ->where('create_time', '<', $ds4)->count();

            $data[] = $ky;
            $value[] = $count;

        }
        return json(['code'=>1,'data'=>$data,'value'=>$value]);

    }


}
